//
//  FGBubbleMessageCellData.m
//  FGChatKit
//
//  Created by Henry on 2020/8/13.
//  Copyright © 2020 Henry. All rights reserved.
//

#import "FGBubbleMessageCellData.h"
#import "UIColor+FGChat.h"
#import "UIImage+FGUtil.h"

@implementation FGBubbleMessageCellData

- (instancetype)initWithDirection:(FGMsgDirection)direction {
    self = [super initWithDirection:direction];
    if (self) {
        if (direction == FGMsgDirectionIncoming) {
            _bubble = [[self class] incommingBubble];
            _highlightedBubble = [[self class] incommingHighlightedBubble];
                        
            self.cellLayout = [FGMessageCellLayout incommingBubbleMessageLayout];
        } else {
            _bubble = [[self class] outgoingBubble];
            _highlightedBubble = [[self class] outgoingHighlightedBubble];
            self.cellLayout = [FGMessageCellLayout outgoingBubbleMessageLayout];
        }
    }
    return self;
}


static UIImage *sOutgoingBubble;

+ (UIImage *)outgoingBubble {
    if (!sOutgoingBubble) {
        UIColor *color = [UIColor fg_colorWithLightColor:[UIColor fg_colorWithString:@"#558DFF"] darkColor:[UIColor fg_colorWithString:@"#B0E46E"]];
        sOutgoingBubble = [UIImage imageSenderWithColor:color];
    }
    return sOutgoingBubble;
}

+ (void)setOutgoingBubble:(UIImage *)outgoingBubble {
    sOutgoingBubble = outgoingBubble;
}

static UIImage *sOutgoingHighlightedBubble;

+ (UIImage *)outgoingHighlightedBubble {
    if (!sOutgoingHighlightedBubble) {
        UIColor *color = [UIColor fg_colorWithLightColor:[UIColor fg_colorWithString:@"#9ECC63"] darkColor:[UIColor fg_colorWithString:@"#9ECC63"]];
        sOutgoingHighlightedBubble = [UIImage imageSenderWithColor:color];
    }
    return sOutgoingHighlightedBubble;
}

+ (void)setOutgoingHighlightedBubble:(UIImage *)outgoingHighlightedBubble {
    sOutgoingHighlightedBubble = outgoingHighlightedBubble;
}

static UIImage *sIncommingBubble;

+ (UIImage *)incommingBubble {
    if (!sIncommingBubble) {
        UIColor *color = [UIColor fg_colorWithLightColor:[UIColor fg_colorWithString:@"#F0F2F5"] darkColor:[UIColor fg_colorWithString:@"#333333"]];
        sIncommingBubble = [UIImage imageReceiverWithColor:color];
    }
    return sIncommingBubble;
}

+ (void)setIncommingBubble:(UIImage *)incommingBubble {
    sIncommingBubble = incommingBubble;
}

static UIImage *sIncommingHighlightedBubble;

+ (UIImage *)incommingHighlightedBubble {
    if (!sIncommingHighlightedBubble) {
        UIColor *color = [UIColor fg_colorWithLightColor:[UIColor fg_colorWithString:@"#E5E5E5"] darkColor:[UIColor fg_colorWithString:@"#E5E5E5"]];
        sIncommingHighlightedBubble = [UIImage imageReceiverWithColor:color];
    }
    return sIncommingHighlightedBubble;
}

+ (void)setIncommingHighlightedBubble:(UIImage *)incommingHighlightedBubble {
    sIncommingHighlightedBubble = incommingHighlightedBubble;
}

@end
